<template>
  <div class="TabRight">
    <Yqfw @fatherMethod="fatherMethodYqfw" ref="Yqfw"></Yqfw>
    <CrowdedPlace
      @fatherMethod="fatherMethodCrowdedPlace"
      ref="CrowdedPlace"
    ></CrowdedPlace>
  </div>
</template>
<script lang="ts">
import { Component, Vue, Prop, Watch } from "vue-property-decorator";
import Yqfw from "@/views/wsyj/ZhtsModule/Yqfw.vue";
import CrowdedPlace from "@/views/wsyj/ZhtsModule/CrowdedPlace.vue";
import MapCommon from "@/util/MapCommon";
@Component({
  name: "TabRight",
  components: {
    Yqfw,
    CrowdedPlace
  },
  mixins: [MapCommon]
})
export default class TabRight extends Vue {
  private MapComp: any;
  // 观察左侧三个 重置右侧图标
  @Watch("$store.state.ZhtsModule.tuliType")
  private getClearAllActive(newVal: any, oldVal: any) {
    (this.$refs as any).CrowdedPlace.cleardata();
    (this.$refs as any).Yqfw.cleardata();
    this.MapComp.removePointLayer();
    this.$store.dispatch("ZhtsModule/setQunyiqingType", '' );

  }

  @Watch("$store.state.cityListModule.checkedCityObj.id")
  private getCurrentId(newVal: any, oldVal: any) {
    const typecode : string = this.$store.state.ZhtsModule.qunyiqingType;
    if(typecode){
      this.MapComp.removePointLayer();
      this.MapComp.addPointByType(newVal, typecode);
    }

  }
  @Watch("$store.state.cityListModule.outChangeid")
  private getOutId(newVal: any, oldVal: any) {
    const typecode : string = this.$store.state.ZhtsModule.qunyiqingType;
    if(typecode){
      this.MapComp.removePointLayer();
      this.MapComp.addPointByType(newVal, typecode);
    }

  }



  // 互斥邏輯，杜志勛補充 2020/2/7 ----------------
  private fatherMethodYqfw(data: any) {
    (this.$refs as any).CrowdedPlace.cleardata();
  }
  private fatherMethodCrowdedPlace(data: any) {
    (this.$refs as any).Yqfw.cleardata();
  }
  private getComponent() {
    const self: any = this;
    const modules = self.$ioc.resolve("GISModules-map");
    const component = modules.eventSituation.getComponent("compresituation");
    return component;
  }
  public beforeDestroy() {
    this.$store.dispatch("ZhtsModule/setQunyiqingType", '' );
  }

  private mounted() {
    (this as any).resolveMap("map").then(() => {
      this.MapComp = this.getComponent();
    });
  }
  // ------------------------------------------------
}
</script>
<style lang="less" scoped></style>
